import java.awt.event.*;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;

public class ConfigurationMenuListener implements ActionListener {
   private MyWorld  world;
   public ConfigurationMenuListener (MyWorld  w){
      world = w;
   }
   public void actionPerformed(ActionEvent e) {
      JMenuItem menuItem = (JMenuItem)(e.getSource());
      String text = menuItem.getText();
      if (text.equals("Ball")) {
         String data = JOptionPane.showInputDialog("Enter Mass [kg]","1");
         world.addElement(new GBall(Float.parseFloat(data), new Vector2D(2f,1f), new Vector2D(), 0.13f));}
      if (text.equals("Fixed Hook")) 
         world.addElement(new GFixedHook(new Vector2D(2f,3f), 0.2f));
      if (text.equals("Spring")){
         String data = JOptionPane.showInputDialog("Enter Stiffness [N/m]","20");
         world.addElement(new GSpring (2f, Float.parseFloat(data)));}
      if (text.equals("Rubber")){
         String data = JOptionPane.showInputDialog("Enter Stiffness [N/m]","20");
         world.addElement(new GRubber (2f, Float.parseFloat(data)));}
      if (text.equals("Delete"))
         world.delete();
      if (text.equals("Select Ball"))
         world.select();
      if (text.equals("Set attribute..."))
         world.set();
   }
}